module ApplicationHelper
  def notice_message
    alert_types = { notice: :success, alert: :danger }
    # 给警告框添加一个可关闭按钮
    close_button_options = { class: "close", "data-dismiss" => "alert", "aria-hidden" => true }
     close_button = content_tag(:button, "×", close_button_options)
     # flash存在于哪里呢？其实是保存在session中，这样就可以在客户端与服务器双向通信。

     alerts = flash.map do |type, message|
       alert_content = close_button + message

       alert_type = alert_types[type.to_sym] || type
       alert_class = "alert alert-#{alert_type} alert-dismissable"
       # 得到一个div标签内容
       content_tag(:div, alert_content, class: alert_class)
     end

     alerts.join("\n").html_safe
   end

end
